package cn.wolfcode.p2p.website.controller;

import cn.wolfcode.p2p.base.excetion.DisplayableExcetion;
import cn.wolfcode.p2p.base.util.AjaxResult;
import cn.wolfcode.p2p.bussness.domain.RechargeOffline;
import cn.wolfcode.p2p.bussness.service.IPlatformBankInfoService;
import cn.wolfcode.p2p.bussness.service.IRechargeofflineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//线下重置
@Controller
public class RechargeofflineController {

    @Autowired
    private IPlatformBankInfoService platformBankInfoService;
    @Autowired
    private IRechargeofflineService rechargeofflineService;

    @RequestMapping("/recharge")
    public String basicInfo(Model model){
        model.addAttribute("banks",platformBankInfoService.selectAll());
        return "/recharge";
    }

    //充值提交
    @RequestMapping("/recharge_save")
    @ResponseBody
    public AjaxResult rechargeSave(RechargeOffline rechargeOffline){
        AjaxResult result = null;
        try {
            rechargeofflineService.apply(rechargeOffline);
            result = new AjaxResult();
        } catch (DisplayableExcetion e) {
            e.printStackTrace();
            result = new AjaxResult(false, e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            result = new AjaxResult(false, "系统出错,请联系管理员");
        }
        return result;
    }



}
